﻿<Page x:Class="SSDM.NewMain"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:MyControl="clr-namespace:MPL.MyControls;assembly=MPL"
    xmlns:CommonControl="clr-namespace:SSDM.CommonUI"
    WindowTitle="SqlCeViewer" 
    Title="SqlCeViewer" MaxHeight="768" MaxWidth="1024">
    <Page.Resources>
        <Style x:Key="listBoxItemStyle" TargetType="{x:Type ListBoxItem}">
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                                Color="LightYellow"/>
            </Style.Resources>
        </Style>
        <Storyboard x:Key="appendixPanelStoryStart" x:Name="appendixPanelStoryStart">
            <DoubleAnimation By="200" Duration="00:00:01"
                Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="appendixPanel"
                />
        </Storyboard>
        <Storyboard x:Key="appendixPanelStoryEnd" x:Name="appendixPanelStoryEnd">
            <DoubleAnimation To="0" Duration="00:00:01"
                Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="appendixPanel"
                />
        </Storyboard>
    </Page.Resources>
    <Grid>
        <DockPanel>
            <StackPanel Margin="2">
                <MyControl:ScrollableListBox 
                    Height="200" Panel.ZIndex="1" ItemContainerStyle="{StaticResource listBoxItemStyle}"
                                          ScrollViewer.IsDeferredScrollingEnabled="False"
                         ScrollViewer.HorizontalScrollBarVisibility="Visible"
                     ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="5,20,5,2"
                ItemsSource="{Binding}" x:Name="DbCollectionList" >
                    <MyControl:ScrollableListBox.BitmapEffect>
                        <BlurBitmapEffect Radius="0.5" KernelType="Box" />
                    </MyControl:ScrollableListBox.BitmapEffect>
                    <MyControl:ScrollableListBox.BorderBrush>
                            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                <GradientStop Color="Transparent" Offset="0.0" />
                                <GradientStop Color="SkyBlue" Offset="0.25" />
                                <GradientStop Color="SkyBlue" Offset="0.75" />
                                <GradientStop Color="Transparent" Offset="1.0" />
                            </LinearGradientBrush>
                    </MyControl:ScrollableListBox.BorderBrush>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Border Width="120" Height="Auto"
                            Tag="{Binding Path=NewURL}"
                            MouseLeftButtonDown="Border_MouseLeftButtonDown"
                                    MouseEnter="Border_MouseEnter"
                                    MouseLeave="Border_MouseLeave"
                        Margin="15">
                                <StackPanel>
                                    <Image Source="{Binding Path=LogoImage}" 
                                       PreviewMouseLeftButtonDown="Image_PreviewMouseLeftButtonDown_ForEntry"
                                       Tag="{Binding Path=NewURL}" Height="100">
                                        <Image.ToolTip>
                                            <StackPanel Opacity="0.8">
                                                <TextBlock Text="{Binding Path=ToolTipText}"/>
                                            </StackPanel>
                                        </Image.ToolTip>
                                    </Image>
                                    <TextBlock Text="{Binding Path=Comment}" HorizontalAlignment="Center"></TextBlock>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel Orientation="Horizontal"></VirtualizingStackPanel>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                </MyControl:ScrollableListBox>
                <Border Width="{Binding ElementName=DbCollectionList,Path=ActualWidth}" Margin="0 -20 0 10" Height="150" 
                        BorderThickness="5" BorderBrush="White">
                    <Border.Background>
                        <VisualBrush Visual="{Binding ElementName=DbCollectionList}">
                            <VisualBrush.Transform>
                                <ScaleTransform ScaleX="1" ScaleY="-1" CenterX="200" CenterY="75"></ScaleTransform>
                            </VisualBrush.Transform>
                        </VisualBrush>
                    </Border.Background>
                    <Border.OpacityMask>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Offset="0" Color="Black"></GradientStop>
                            <GradientStop Offset="0.6" Color="Transparent"></GradientStop>
                        </LinearGradientBrush>
                    </Border.OpacityMask>
                </Border>
                <!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom">
                    <Label Width="131" Foreground="LightBlue">Skin</Label>
                    <ComboBox  HorizontalAlignment="Left" Name="themes"
                  SelectionChanged="themes_SelectionChanged"
                  SelectedIndex="0" Width="150" />
                </StackPanel>-->
                <MyControl:ScrollableListBox x:Name="themeListBox" 
                                             BorderThickness="5,20,5,20"
                                             ItemsSource="{Binding}"
                         ScrollViewer.IsDeferredScrollingEnabled="False"
                         ScrollViewer.HorizontalScrollBarVisibility="Visible"
                     ScrollViewer.VerticalScrollBarVisibility="Visible">
                    <ListBox.ToolTip>
                        <StackPanel>
                            <StackPanel Width="400">
                                <Label FontWeight="Bold" Background="LightCyan" Foreground="Red">Tips</Label>
                                <TextBlock Margin="4,4,0,0" Text="You can right click to restore to default theme" FontSize="12"></TextBlock>
                                <Line Stroke="Black" StrokeThickness="1" Width="400">
                                </Line>
                                <StackPanel Orientation="Horizontal">
                                    <Label FontWeight="Bold">
                                        Home Page : https://sourceforge.net/projects/sqlceviewer
                                    </Label>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                    </ListBox.ToolTip>
                    <ListBox.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Restore theme" Click="MenuItem_Click"/>
                        </ContextMenu>
                    </ListBox.ContextMenu>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Border Width="20" Height="Auto"
                                    MouseEnter="Border_MouseEnter_Theme"
                                    MouseLeave="Border_MouseLeave_Theme"
                        Margin="15">
                                <StackPanel>
                                    <Image Source="{Binding Path=ThemeIcon}"
                                           Tag="{Binding}" 
                                           PreviewMouseLeftButtonDown="Image_PreviewMouseLeftButtonDown"
                                           Height="20">
                                        <Image.ToolTip>
                                            <StackPanel>
                                                <TextBlock Text="{Binding ThemeName}"></TextBlock>
                                            </StackPanel>
                                        </Image.ToolTip>
                                    </Image>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel Orientation="Horizontal"></VirtualizingStackPanel>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <MyControl:ScrollableListBox.BorderBrush>
                        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                            <GradientStop Color="Transparent" Offset="0.0" />
                            <GradientStop Color="SkyBlue" Offset="0.25" />
                            <GradientStop Color="SkyBlue" Offset="0.75" />
                            <GradientStop Color="Transparent" Offset="1.0" />
                        </LinearGradientBrush>
                    </MyControl:ScrollableListBox.BorderBrush>
                </MyControl:ScrollableListBox>
                <Button x:Name="butCallAppendixPanel" Click="butCallAppendixPanel_Click"
                        HorizontalAlignment="Right" Margin="0 0 10 0">
                        <Button.Content>
                        <StackPanel Orientation="Horizontal">
                            <Path StrokeThickness="1.500000" Stroke="#ffffffff" StrokeMiterLimit="1.000000" 
              Fill="Blue"
              Data="F1 M 9.816406,1.694336 L 12.351074,6.830078 L 18.018066,7.654297 L 13.918457,11.654297 L 14.886230,17.299805 L 9.816406,14.630859 L 4.746094,17.299805 L 5.713867,11.654297 L 1.611328,7.654297 L 7.281250,6.830078 L 9.816406,1.694336 Z" 
              HorizontalAlignment="Left" VerticalAlignment="Center" x:Name="Star"/>
                            <TextBlock Margin="1 0 1 0"  Text="Appendix" TextAlignment="Center" VerticalAlignment="Center" /> 
                        </StackPanel>
                    </Button.Content>
                </Button>
                    <CommonControl:AppendixPanel x:Name="appendixPanel" Height="0"/>
            </StackPanel>

        </DockPanel>
        <Path StrokeThickness="1.500000" Stroke="#ffffffff" StrokeMiterLimit="1.000000" 
              Fill="Blue" PreviewMouseLeftButtonDown="CallTraditioalWind_PreviewMouseLeftButtonDown"
              Data="F1 M 9.816406,1.694336 L 12.351074,6.830078 L 18.018066,7.654297 L 13.918457,11.654297 L 14.886230,17.299805 L 9.816406,14.630859 L 4.746094,17.299805 L 5.713867,11.654297 L 1.611328,7.654297 L 7.281250,6.830078 L 9.816406,1.694336 Z" 
              HorizontalAlignment="Left" VerticalAlignment="Center" x:Name="CallTraditioalWind" 
              ToolTip="Press here to change to 3D view"/>
    </Grid>
</Page>
